import { makeAutoObservable, computed } from "mobx";

export class ListStore {
  list = [1,2,3]
  channelList = []
  constructor() {
    makeAutoObservable(this, {
      filterList: computed
    })
  }

  get filterList() {
    return this.list.filter(item => item > 2)
  }

  pushList = (value) => {
    this.list.push(value)
  }

  setChannelList = async () => {
    const res = await fetch('http://geek.itheima.net/v1_0/channels').then(resp => resp.json())
    this.channelList = res.data.channels
  }

}
